using System;
using System.Collections.Generic;

namespace AreaGenerator
{
	public class Node
	{
		public int x;
		public int y;
		
		public Node north;
		public Node south;
		public Node east;
		public Node west;
		
		
		public Node(int x, int y){
			this.x = x;
			this.y = y;
		}
		
		public void setAdjacentNodes(Node n, Node s, Node e, Node w){
			north = n;
			south = s;
			east = e;
			west = w;
		}
		
		public bool isAdjacent(Node n){
			return (north!=null && north.Equals(n)) || (south!=null && south.Equals(n)) || (east!=null && east.Equals(n)) || (west!=null && west.Equals(n));
			
		}
		
		public override bool Equals(Object node){
			Node n = node as Node;
			return this.x == n.x && this.y == n.y;
		}
		
		public override int GetHashCode(){
			return x^y;
		}
		
		public override String ToString(){
			return "Node(" + x + ";" + y + ")";
		}
	}
}

